# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=hadrian
pkgname=haskell-hadrian
pkgver=0.1.0.0
_ghcver=9.2.3
pkgrel=85
pkgdesc="GHC build system"
url="https://gitlab.haskell.org/ghc/ghc"
license=("BSD")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-quickcheck' 'haskell-extra' 'haskell-shake'
         'haskell-unordered-containers')
makedepends=('ghc')
source=("https://downloads.haskell.org/~ghc/$_ghcver/ghc-${_ghcver}-src.tar.xz")
sha256sums=('50ecdc2bef013e518f9a62a15245d7db0e4409d737c43b1cea7306fd82e1669e')

build() {
  cd ghc-$_ghcver/hadrian

  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
    --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --datasubdir=haskell-hadrian --enable-tests \
    --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
    --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
    --ghc-option='-pie' \
    -fthreaded

  runhaskell Setup build $MAKEFLAGS
}

package() {
  cd ghc-$_ghcver/hadrian

  runhaskell Setup copy --destdir="$pkgdir"
  install -D -m644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
  rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
